package com.itheima.huike.exception;

import com.itheima.huike.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionControllerAdvice {

    @ExceptionHandler
    public R ex1(RuntimeException e) {
        log.error("出现了RuntimeException异常....");
        e.printStackTrace();
        return R.error("系统繁忙,请稍后重试...");
    }

    @ExceptionHandler
    public R ex2(Exception e) {
        log.error("出现了Exception异常....");
        e.printStackTrace();
        return R.error("系统繁忙,请稍后重试...");
    }

    @ExceptionHandler
    public R ex3(NullPointerException e) {
        log.error("出现了NullPointerException异常....");
        e.printStackTrace();
        return R.error("系统繁忙,请稍后重试...");
    }
}
